extends Node

@onready var dialogue_ui: Control = $CanvasLayer/DialogueUI
@onready var letter_ui: Control = $CanvasLayer/LetterUI
@onready var animation_player: AnimationPlayer = $AnimationPlayer

var is_end: bool = false
var player_should: bool = false

func instance_node(node, parent, pos, visible: bool = true):
	var instance_nodes = node.instantiate()
	instance_nodes.visible = visible
	instance_nodes.global_position = pos
	parent.call_deferred("add_child",instance_nodes)
	return instance_nodes

func change_scene(path: String):
	var tree := get_tree()
	tree.paused = true
	animation_player.play("change_scene")
	await animation_player.animation_finished
	
	tree.change_scene_to_file(path)
	
	tree.paused = false
	animation_player.play_backwards("change_scene")

func reset_game():
	is_end = false
	player_should = false

func new_game():
	reset_game()
	change_scene("res://scenes/game_main/game.tscn")

func game_end():
	change_scene("res://scenes/UI/game_end.tscn")
